#ifndef __HEADER_BITS__
#define __HEADER_BITS__

#include "crypto/types.h"

typedef struct
{
    int len;
    byte data[];
} bits;

typedef enum
{
    BIT_AND,
    BIT_OR,
    BIT_XOR,
    BIT_NOT
} BIT_OPT;

const static byte orArray[] = {128, 64, 32, 16, 8, 4, 2, 1};

bits *initBits(int len);
void setBitFromBytes(bits *buffer, byte *data, uint len);
void setBit(bits *buffer, int index, uint8 bit);
uint8 getBit(bits *buffer, int index);
uint8 getBitFromArray(byte *buffer, uint index);
void setBit(bits *buffer, int index, uint8 bit);
void rotateBits(bits *buffer, int step);
void operateBits(bits *dst, bits *res, BIT_OPT opt);

#ifndef PRODUCT
void printBits(bits *buffer);
#endif

#endif